async function downloadFile() {
    const fileName = "QQ2025310-14483-HD.mp4";  // 目标文件名
    const chunkSize = 1024 * 1024;     // 分片大小（1MB）
    let currentChunk = 0;
    let totalChunks = 0;
    let fileBlobs = [];

    // 获取文件总大小
    const response = await fetch(`/download/${fileName}`, { method: 'HEAD' });
    const totalSize = parseInt(response.headers.get('Content-Length'), 10);
    totalChunks = Math.ceil(totalSize / chunkSize);

    // 分片下载循环
    while (currentChunk < totalChunks) {
        const start = currentChunk * chunkSize;
        const end = Math.min(start + chunkSize - 1, totalSize - 1);

        const chunkResponse = await fetch(`/download/${fileName}`, {
            headers: { 'Range': `bytes=${start}-${end}` }
        });

        if (chunkResponse.status === 206) {  // 分片成功‌:ml-citation{ref="3" data="citationList"}
            const blob = await chunkResponse.blob();
            fileBlobs.push(blob);
            currentChunk++;
            console.log(`已下载分片 ${currentChunk}/${totalChunks}`);
        } else {
            console.error("分片下载失败");
            break;
        }
    }

    // 合并分片并触发下载
    const fullBlob = new Blob(fileBlobs);
    const downloadUrl = window.URL.createObjectURL(fullBlob);
    const link = document.createElement('a');
    link.href = downloadUrl;
    link.download = fileName;
    link.click();
    window.URL.revokeObjectURL(downloadUrl);
}